import request from '@/utils/request'
import repairAudit from "@/views/assets/assets/RepairAudit.vue";

// 查询基础信息管理列表
export function listAssets(query) {
  return request({
    url: '/assets/repair/list',
    method: 'get',
    params: query
  })
}

// 查询基础信息管理详细
export function getAssets(assetId) {
  return request({
    url: '/assets/repair/' + assetId,
    method: 'get'
  })
}

// 新增基础信息管理
export function addAssets(data) {
  return request({
    url: '/assets/repair',
    method: 'post',
    data: data
  })
}

// 修改基础信息管理
export function updateAssets(data) {
  return request({
    url: '/assets/repair',
    method: 'put',
    data: data
  })
}

// 删除基础信息管理
export function delAssets(assetId) {
  return request({
    url: '/assets/repair/' + assetId,
    method: 'delete'
  })
}

export function requestRepair(data) {
  // 将 repairReason 作为查询参数传递
  const params = {
    repairReason: data.repairReason
  };

  // 将 oliveAssets 对象作为请求体传递
  const requestData = data.oliveAssets;

  return request({
    url: '/assets/repair/request',
    method: 'post',
    params: params, // 传递查询参数
    data: requestData, // 传递请求体
    headers: {
      'Content-Type': 'application/json' // 确保设置正确的 Content-Type
    }
  });
}





export function returnAsset(data) {
  return request({
    url: '/assets/repair/return',
    method: 'post',
    data: data
  });
}
export function approveRepair(repairAudit) {
  return request({
    url: '/assets/repair/approve/' + repairAudit.repairApplicationId, // 使用 borrowLogId 作为路径参数
    method: 'post',
    data: repairAudit // 将整个 repairAudit 对象作为请求体
  });
}

export function rejectRepair(repairAudit) {
  return request({
    url: '/assets/repair/reject/' + repairAudit.repairApplicationId, // 使用 borrowLogId 作为路径参数
    method: 'post',
    data: repairAudit // 将整个 repairAudit 对象作为请求体
  });
}

// 开始维修
export function startRepair(repairAudit) {
  return request({
    url: '/assets/repair/start/' + repairAudit.repairApplicationId,
    method: 'post',
    data: repairAudit
  });
}

// 完成维修
export function finishRepair(repairAudit) {
  return request({
    url: '/assets/repair/finish/' + repairAudit.repairApplicationId,
    method: 'post',
    data: repairAudit
  });
}
